package com.lhd.controller;


import com.alibaba.fastjson.JSONObject;
import com.lhd.bean.GoodsUvCt;
import com.lhd.bean.OrderRate;
import com.lhd.service.GoodsService;
import com.lhd.service.OrderRateService;
import com.lhd.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/gmall/realtime/user")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;
    @Autowired
    private OrderRateService orderRateService;

    @RequestMapping("/goodsUv")
    public List<JSONObject> getUvPerPage(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> uvList = goodsService.getGoodsUv(date);

        return  uvList;
    }

    @RequestMapping("/orderRate")
    public List<JSONObject> getOrderRate(
            @RequestParam(value = "date", defaultValue = "1") Integer date) {
        if (date == 1) {
            date = DateUtil.now();
        }
        List<JSONObject> orList = orderRateService.getOrderRate(date);


        return  orList;
    }



}
